﻿Shader "Custom/SquireGrid"
{
    Properties
    {
        _MainTex ("Image", 2D) = "white" {}
//        _BaseColor("_BaseColor", Color) = (0.74, 0.74, 0.74, 1)
    }
    SubShader
    {
        Tags
        {
            "Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="AlphaTest"
        }
        Cull Off
        Lighting Off
        ZWrite On
        ZTest LEqual
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_instancing
            #pragma instancing_options assumeuniformscaling procedural:ConfigureProcedural
            #pragma editor_sync_compilation
            #pragma target 4.5
            #include "UnityCG.cginc"

            struct appdata_t
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct v2f
            {
                float4 vertex : SV_POSITION;
                float2 uv : TEXCOORD0;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };
            sampler2D _MainTex;
            float _Cutoff;
            float _Alpha;
            #if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
                StructuredBuffer<float4> _BaseColor;
                StructuredBuffer<float4x4> _TransMatrices;
            #endif

            void ConfigureProcedural () {
                #if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
                    unity_ObjectToWorld = _TransMatrices[unity_InstanceID];
                #endif
            }

            float4 GetColor()
            {
                #if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
                return _BaseColor[unity_InstanceID];
                #else
                return float4(1, 1, 1, 1);
                #endif
            }

            v2f vert(appdata_t i)
            {
                v2f o;
                UNITY_SETUP_INSTANCE_ID(i);
                UNITY_TRANSFER_INSTANCE_ID(i, o);
                o.vertex = UnityObjectToClipPos(i.vertex);
                o.uv = i.uv;
                return o;
            }

            float4 frag(v2f i) : SV_Target
            {
                UNITY_SETUP_INSTANCE_ID(i);
                return GetColor();
            }
            ENDCG
        }
    }
}